﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using E.BLL;
using E.Web.UI.Page;
using X.Common;
using E.Model;
using X.Pager;
using X.Pager.List;

namespace E.Web.training.internals.course
{
    public partial class FreeCourseList : BasePage
    {
        public Dictionary<int, string> courseList = new Dictionary<int, string>();
        public string act;
        public int courseid;
        public IList<InternalFreeCourseModel> freecCourseList;

        protected override void ShowPage()
        {
            int projectid = (new UserBLL()).GetUserProjectID(userid);
            UserModel userModel = (new UserBLL()).GetUserInfoByUserID(userid);

            courseList = (new CourseBLL()).GetCourseListByCertificateID(projectid);

            act = XRequest.GetString("act");
            courseid = XRequest.GetInt("CourseSlt", -1);


            if (ispost || act == "s")
            {
                CourseBLL cll = new CourseBLL();

                InternalFreeCourseSearchModel searchModel = new InternalFreeCourseSearchModel();
                searchModel.CourseID = courseid;
                searchModel.ProjectID = projectid;
                searchModel.DelFlag = 0;
                searchModel.SkillGroup = userModel.SkillGroupId;

                InternalFreeCourseListModel listModel = new InternalFreeCourseListModel();

                CheckPageIndexValue(XRequest.GetInt("s", 1) - 1, XRequest.GetInt("g", 0), XRequest.GetInt("z", customerPageSize));

                listModel = cll.GetInternalFreeCourseListByCondition(searchModel, customerPageSize, pageIndex);
                if (listModel.TotalCount > 0)
                {
                    count = listModel.TotalCount;
                    freecCourseList = listModel.List;
                    PagerBase pager = new ListPager(count, pageIndex, currentPgGroup, customerPageSize, defaultPagesInGroup);

                    Dictionary<string, string> parms = new Dictionary<string, string>();
                    parms.Add("act", act);
                    parms.Add("CourseSlt", courseid.ToString());
                    parms.Add("ProjectSlt", projectid.ToString());
                    parms.Add("AreaSlt", areaid.ToString());
                    mypager = pager.DrawPager("selfpager", parms);
                }
                //}
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {

        }
    }
}